Log in to ask questions, share your expertise, or stay connected to content you value. Don’t have a login? Learn how to become a member.
See matching posts in thread - PyEz Inline Table View...
Define a Table View to Access Table Item Fields You generally define a Table View when you define the Table in operational or configuration mode. The purpose of a View is to map the Junos XML fields into native Python so the caller doesn't need to know XML (or Junos OS). For example, the same Ethernet Port Table used is as presented in the Define Operational Table page. The View is associated to the table on line 9: 1 -- 2 EthPortTable: 3 rpc: get-interface-information 4 args: 5 media: True 6 interface name: '[afgx]e*' 7 args key: interface name 8 item: physical-interface 9 view: EthPortView Example The following illustrates the EthPortView YAML definition which is used for the example
See the troubleshooting document titled Defining a Table View under Junos PyEZ
The following is an example that corresponds to the Junos OS CLI command to display the interface media data for all Ethernet interfaces (ae*, fe*, ge*, and xe*): show interfaces media "[afgx]e*" Example 1 -- 2 EthPortTable: 3 rpc: get-interface-information 4 args: 5 media: True 6 interface name: '[afgx]e*' 7 args key: interface name 8 item: physical-interface 9 view: EthPortView Discussion Table Name (REQUIRED) You can choose to call your table definition anything you want
3 Comments - jie.gao@zxtac.com says: Hi , Can I use Tables and views to get subscribers table? I try create two file as "testsubscriber.py" and "testsubscriber.yml" in "/usr/local/lib/python2.7/dist-packages/jnpr/junos/op". The testsubscriber.py content as: """ Python for Subscriber Table/View """ from jnpr.junos.factory import loadyaml from os.path import splitext YAML = splitext( file )[0] + '.yml' globals().update(loadyaml( YAML )) The testsubscriber.yml content as: -- Show subscriber: rpc: get-subscribers item: .//subscriber view: SubscriberView SubscriberView: fields: interface: interface username: user-name I try it in python shell as: from jnpr.junos import Device from jnpr.junos.op.testsubscriber import * dev = Device(host = "x.x.x.x",user = "lab",password = "lab123") I can get dev.facts success but I try : >>> dir() ['Show subscriber', 'SubscriberView', ' builtins ', ' doc ', ' name ', ' package ', 'dev', 'loadyaml', 'login', 'splitext'] >>> Show subscriber(dev) Show subscriber:x.x.x.x - Table empty >>> subscribers = Show subscriber(dev) >>> subscribers.get() Show subscriber:x.x.x.x: 0 items why I get subscibers with 0 items, in facts there a 126 subscribers
The Troubleshooting, Auditing, and Reporting page in Junos PyEZ contains instructions on how to retrieve operational and configuration data in tables and views using Junos PyEZ. This page also has the following child pages: Define Configuration Table Define Operational Table Defining a Table View Loading YAML Using Tables Using Views #How-To #junospyez #Python
About Junos PyEZ Junos PyEZ is a microframework for Python that enables you to remotely manage and automate devices running Junos OS. Official Documentation Junos PyEZ technical documentation Junos PyEZ documentation in GitHub API documentation on readthedocs.org All Junos PyEZ releases in GitHub Latest Junos PyEZ release notes General Resources JunosPyEZ Features and Architecture This document describes Junos PyEZ, lists its features, and explains its architecture
The purpose of Junos PyEZ is to abstract, or insulate, the user of the Table/View from this information. The View widgets are defined using YAML in a similar process as the Tables
3 Comments - no search term matches found in comments.
Create Tables or Views for Complex Use Cases You can create Tables/Views for complex use cases, such as a multi-path route lookup
Read the Configuration Out of a Junos Device Using Tables and Views Using the SRX examples in GitHub, https://github.com/Juniper/py-junos-.../cfgro/srx.yml , the Table uses get to retrieve a configuration stanza. A VRF query table was created below that is in a position to retrieve all the VRF instance names, and succesfully load all VRF instance names. VRF Query Table/View VRF: 1 get: routing-instances/instance args key: name view: VRFView VRFView: fields: instance name: name To retrieve entire sections of the configuration and group per instance, the PyEZ techwiki specifies that configuration can be retrieved using Table/View. To Retrieve Using Table/View: Yaml file content (change according to your need): VRF: get: routing-instances/instance args key: name view: VRFView VRFView: fields: instance name: name instance type: instance-type rd type: route-distinguisher/rd-type vrf import: vrf-import vrf export: vrf-export Code: tbl = VRF(dev) #The change is below set the value=True
1 Comment - sotiris.ioannou@interoute.com says: The answer was provided by Nitin Kumar on the PyEZ Google Group: Please try out this way: Yaml file content (change according to your need): VRF: get: routing-instances/instance args key: name view: VRFView VRFView: fields: instance name: name instance type: instance-type rd type: route-distinguisher/rd-type vrf import: vrf-import vrf export: vrf-export Code: tbl = VRF(dev) #The change is below set the value=True
If you do not pass any arguments to get() , then all of the table items will be extracted from the Junos OS device...This Table widget is provided by Junos PyEZ
1 Comment - no search term matches found in comments.